__author__ = 'mayday'
# Define a procedure, median, that takes three
# numbers as its inputs, and outputs the median
# of the three numbers.

# Make sure your procedure has a return statement.

def bigger(a, b):
    if a > b:
        return a
    else:
        return b


def biggest(a, b, c):
    return bigger(a, bigger(b, c))


def median(a, b, c):
    if a == biggest(a, b, c):
        return bigger(b, c)
    if b == biggest(a, b, c):
        return bigger(a, c)
    else:
        return bigger(a, b)

# Define a procedure, countdown, that takes a
# positive whole number as its input, and prints
# out a countdown from that number to 1,
# followed by Blastoff!

def countdown(num):
    while num > 0:
        print num
        num -= 1
    print 'Blastoff!'

# Define a procedure, find_last, that takes as input
# two strings, a search string and a target string,
# and outputs the last position in the search string
# where the target string appears, or -1 if there
# are no occurences.
#
# Example: find_last('aaaa', 'a') returns 3

# Make sure your procedure has a return statement.

def find_last(search, target):
    start_flag = -1
    while True:
        i = search.find(target, start_flag + 1)
        if i == -1:
            break
        start_flag = i
    return start_flag

#print find_last('aba', 'a')

#2 GOLD STARS

#Define a procedure,
#print_multiplication_table,
#that takes as input a positive whole
#number, and prints out a multiplication,
#table showing all the whole number
#multiplications up to and including the
#input number. The order in which the
#equations are printed must match exactly.

#print_multiplication_table(2)
#1 * 1 = 1
#1 * 2 = 2
#2 * 1 = 2
#2 * 2 = 4

def print_multiplication_table(n):
    i = 1
    while i <= n:
        j = 1
        while j <= n:
            print i, ' * ', j, ' = ', i * j
            j += 1
        i += 1

print_multiplication_table(5)